import { Component, OnInit, Input, EventEmitter, Output, ViewChild, ElementRef } from '@angular/core';

@Component({
    moduleId: module.id,
    selector: 'datetimepicker',
    templateUrl: 'datetimepicker.component.html'
})
export class DateTimePickercomponent implements OnInit {
    constructor() {}

    @ViewChild("timepicker")
    timepicker: ElementRef;

    ngOnInit() {
        let dp = $(this.timepicker.nativeElement);
        dp.datetimepicker({
            format: "YYYY-MM-DD",
            locale: 'zh-cn'
        });
        dp.on('dp.change', (e: any) => {
            this.DateTime = e.date.format("YYYY-MM-DD");
            this.DateTimeChange.emit(this.DateTime);
        });
    }

    @Input()
    DateTime: any;

    @Output()
    DateTimeChange = new EventEmitter<any>();
}

declare const $: any;